package com.ruoyi.camp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.camp.domain.CFacilityType;
import com.ruoyi.camp.service.ICFacilityTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * typeController
 * 
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/camp/type")
public class CFacilityTypeController extends BaseController
{
    @Autowired
    private ICFacilityTypeService cFacilityTypeService;

    /**
     * 查询type列表
     */
    @PreAuthorize("@ss.hasPermi('camp:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(CFacilityType cFacilityType)
    {
        startPage();
        List<CFacilityType> list = cFacilityTypeService.selectCFacilityTypeList(cFacilityType);
        return getDataTable(list);
    }

    /**
     * 导出type列表
     */
    @PreAuthorize("@ss.hasPermi('camp:type:export')")
    @Log(title = "type", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CFacilityType cFacilityType)
    {
        List<CFacilityType> list = cFacilityTypeService.selectCFacilityTypeList(cFacilityType);
        ExcelUtil<CFacilityType> util = new ExcelUtil<CFacilityType>(CFacilityType.class);
        util.exportExcel(response, list, "type数据");
    }

    /**
     * 获取type详细信息
     */
    @PreAuthorize("@ss.hasPermi('camp:type:query')")
    @GetMapping(value = "/{ftId}")
    public AjaxResult getInfo(@PathVariable("ftId") String ftId)
    {
        return success(cFacilityTypeService.selectCFacilityTypeByFtId(ftId));
    }

    /**
     * 新增type
     */
    @PreAuthorize("@ss.hasPermi('camp:type:add')")
    @Log(title = "type", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CFacilityType cFacilityType)
    {
        return toAjax(cFacilityTypeService.insertCFacilityType(cFacilityType));
    }

    /**
     * 修改type
     */
    @PreAuthorize("@ss.hasPermi('camp:type:edit')")
    @Log(title = "type", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CFacilityType cFacilityType)
    {
        return toAjax(cFacilityTypeService.updateCFacilityType(cFacilityType));
    }

    /**
     * 删除type
     */
    @PreAuthorize("@ss.hasPermi('camp:type:remove')")
    @Log(title = "type", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ftIds}")
    public AjaxResult remove(@PathVariable String[] ftIds)
    {
        return toAjax(cFacilityTypeService.deleteCFacilityTypeByFtIds(ftIds));
    }
}
